//
//  LinearInterpMainView.m
//  SlideMenu
//
//  Created by khoa nguyen on 7/24/14.
//  Copyright (c) 2014 Aryan Ghassemi. All rights reserved.
//

#import "LinearInterpMainView.h"

@implementation LinearInterpMainView{
    UIBezierPath *mainpath; // (3)
}


- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}


- (id)initWithCoder:(NSCoder *)aDecoder // (1)
{
    if (self = [super initWithCoder:aDecoder])
    {
        [self setMultipleTouchEnabled:NO]; // (2)
        [self setBackgroundColor:[UIColor whiteColor]];
        mainpath = [UIBezierPath bezierPath];
        [mainpath setLineWidth:2.0];
    }
    
    return self;
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

- (void)updateDrawingRect:(LinearInterpView *)delegateObject :(CGPoint)p1 :(CGPoint)p2
{
    NSLog(@"Drawing rect");
    
    [self keepRectangle:p1:p2];
    
}

-(void) keepRectangle:(CGPoint)first_point : (CGPoint) last_point{
    
    CGPoint top_right = first_point;
    CGPoint bottom_left = first_point;
    
    top_right.x = last_point.x;
    top_right.y= first_point.y;
    
    bottom_left.x= first_point.x;
    bottom_left.y= last_point.y;
    
    [mainpath addLineToPoint:bottom_left];
    [mainpath addLineToPoint:last_point];
    [mainpath addLineToPoint:top_right];
    [mainpath addLineToPoint:first_point];
    
    [self setNeedsDisplay];
}

-(void)updateDrawingFree:(LinearInterpView *)delegateObject :(CGPoint)p{
    NSLog(@"Drawing free");
}

@end
